﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Cost.Models;
using NBlock.MVCControl;
using NBlock.Core;
using System.Linq.Expressions;

namespace Cost.Controllers
{
    public class MaterialProcessPlanController : Controller
    {
        #region 构造函数
        private readonly ICostRepository<MaterialProcessPlanView> materialprocessplanRepository;
        private const string State = "Draft";
        public MaterialProcessPlanController(ICostRepository<MaterialProcessPlanView> materialprocessplanRepository)
        {
            this.materialprocessplanRepository = materialprocessplanRepository;
        }
        #endregion

        public ActionResult Index()
        {
            return View();
        }

        [HttpPost]
        public JsonResult List(DateTime? date, nbPageInfo pager, nbSearchCondition where)
        {
            Expression<Func<MaterialProcessPlanView, bool>> filter = null;
            if (date.HasValue)
                filter = m => m.Date == date;

            var pageData = materialprocessplanRepository.GetPageable(pager, filter, where);
            var data = pager.ToGridData(pageData);
            return Json(data);
        }
    }
}
